
public class LC_203 {
    public ListNode removeElements(ListNode head, int val) {
        if(head == null)return head;
        ListNode slow = new ListNode(0), fast = head;
        slow.next = head;
        ListNode key = slow;
        while(fast != null){
            if(fast.val == val){
                slow.next = fast.next;
                fast = fast.next;
            }else{
                slow = slow.next;
                fast = fast.next;
            }
        }
        return key.next;
    }
}
